@extends('layouts.app')

@section('content')
    <section class="content-header">
        <h1 class="pull-left">用户</h1>

    <div class="" style="clear: both">
        {!! Form::open(['route' => 'users.list','method'=>'GET']) !!}
        {!! Form::label('', '选择订单状态:') !!}
        <select name="in_blacklist">
            <option value="">是否加入黑名单</option>
            <option value="1" {{ (isset($request['in_blacklist'])&&$request['in_blacklist'])==='1'?'selected="selected"':'' }}>是</option>
            <option value="0" {{ (isset($request['in_blacklist'])&&($request['in_blacklist']==='0' or $request['in_blacklist']===0))?'selected="selected"':'' }}>否</option>
        </select>
        <input type="text" name="nickname" value="{{ (isset($request['nickname'])&&$request['nickname'])?$request['nickname']:'' }}" placeholder="搜索微信昵称">
        <input type="text" name="xcx_openid" value="{{ (isset($request['xcx_openid'])&&$request['xcx_openid'])?$request['xcx_openid']:'' }}" placeholder="搜索微信openid">
        {!! Form::submit('搜索', ['class' => 'btn btn-primary']) !!}
        {!! Form::close() !!}
    </div>

    </section>
    <div class="content">
        <div class="clearfix"></div>

        @include('flash::message')

        <div class="clearfix"></div>
        <div class="box box-primary">
            <div class="box-body">
                <table class="table table-responsive" id="categories-table">
                    <thead>
                    <th>ID</th>
                    <th>昵称</th>
                    <th>头像</th>
                    <th>性别</th>
                    <th>城市</th>
                    <th>入口</th>
                    <th>上级</th>
                    <th>时间</th>
                    <th colspan="3">操作<th>
                    </thead>
                    <tbody>
                    @foreach($users as $user)
                        <tr>
                            <td>{!! $user->id !!}</td>
                            <td>{!! $user->nickname !!}</td>
                            <td>@tpic($user->avatar_url)</td>
                            <td>{!! $user->sex==1?'男':'女' !!}</td>
                            <td>{!! $user->city !!}</td>
                            <td>{!! $user->openid?'公众号':'' !!} {!! $user->xcx_openid?'小程序':'' !!}</td>
                            <td>{!! ($user->parent_id!=0 && $user->parent)?$user->parent->nickname:'' !!}</td>
                            <td>{!! $user->created_at !!}</td>
                            <td>
                                {!! Form::open(['route' => ['categories.destroy', $user->id], 'method' => 'delete']) !!}
                                <div class='btn-group'>
                                <a href="{!! route('users.setting', ['id'=>$user->id]) !!}" class='btn btn-default btn-xs'>设置</a>
                                <a href="{!! route('users.edit', [$user->id]) !!}" class='btn btn-default btn-xs'>修改</a>
                                <a href="{!! route('orders.index', ['user_id'=>$user->id]) !!}" target="_blank" class='btn btn-default btn-xs'>查看订单</a>
                                <a href="{!! route('categories.edit', [$user->id]) !!}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-edit"></i></a>
                                {!! Form::button('<i class="glyphicon glyphicon-trash"></i>', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!}
                                </div>
                                {!! Form::close() !!}
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    {{ $users->appends($request)->links() }}
    <div id="users-list">
        <router-view></router-view>
    </div>
@endsection

